<template>
    <transition name="modal">
        <div class="modal-mask" @click="$emit('close')">
            <div class="modal-wrapper">
                <div class="modal-container" @click.stop="">
                    <div class="modal-header">
                        <slot name="title">
                            模态框
                        </slot>
                        <span class="icon-close" @click="$emit('close')"></span>
                    </div>
                    <div class="modal-body">
                        <slot name="content">
                            default body
                        </slot>
                    </div>
                    <div class="modal-footer">
                        <slot name="footer">
                            <button class="modal-default-button" @click="$emit('submit'),$emit('close')">
                                <slot name="button-text">
                                    关闭
                                </slot>
                            </button>
                        </slot>
                    </div>
                </div>
            </div>
        </div>
    </transition>
</template>
<style lang="less">
@import "../common/css/flexible.less";
.modal-mask {
    display: flex;
    box-sizing: border-box;
    align-items: center;
    position: fixed;
    z-index: 9998;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, .5);
    transition: opacity .3s ease;
    .rem(padding, 70);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.modal-wrapper {
    flex: 1; // max-height: 100%;
    // overflow-y: scroll;
    // .rem(border-radius, 18);
}

.modal-container {
    background-color: #fff;
    .rem(border-radius, 18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
    transition: all .3s ease;
}

.modal-header {
    position: relative;
    .rem(height, 190);
    .rem(line-height, 190);
    .rem(padding-left, 50);
    .rem(padding-right, 50);
    text-align: center;
    border-bottom: 1px solid #eee;
    .rem(font-size, 56);
    .icon-close {
        display: inline-block;
        position: absolute;
        .rem(top, 65);
        .rem(right, 50);
        .rem(width, 50);
        .rem(height, 50);
        background-image: url(../assets/imgs/close.png);
        background-size: 100% 100%;
        cursor: pointer;
        &:hover {
            background-image: url(../assets/imgs/close-hover.png);
        }
    }
}

.modal-body {
    .rem(padding-left, 50);
    .rem(padding-right, 50);
    .rem(min-height, 200);
}

.modal-footer {
    text-align: center;
    .rem(padding-left, 50);
    .rem(padding-right, 50);
    .rem(padding-bottom, 40);
}

.modal-default-button {
    .rem(height, 120);
    .rem(line-height, 120);
    .rem(font-size, 50);
    .rem(border-radius, 200);
    .rem(padding-left, 200);
    .rem(padding-right, 200);
    text-align: center;
    color: #fff;
    background-color: #16a6ff;
    border: none;
    outline: none;
    box-shadow: 0 5px 8px rgba(0, 0, 0, 0.3);
    &:hover {
        background-color: darken(#16a6ff, 5%)
    }
}





/*
 * The following styles are auto-applied to elements with
 * transition="modal" when their visibility is toggled
 * by Vue.js.
 *
 * You can easily play with the modal transition by editing
 * these styles.
 */

.modal-enter {
    opacity: 0;
}

.modal-leave-active {
    opacity: 0;
}

.modal-enter .modal-container,
.modal-leave-active .modal-container {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
}
</style>
